package mylab.starters.oss.config;

import lombok.Data;
import lombok.EqualsAndHashCode;
import mylab.utils.spring.spi.DefaultProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;

import static mylab.utils.spring.constants.PropertyConst.PROPERTIES_PREFIX;


@Data
@ConfigurationProperties(prefix = OssProperties.PREFIX)
public class OssProperties {

    static final public String PREFIX = PROPERTIES_PREFIX + ".oss";

    /**
     * 阿里云 OSS
     */
    private AliyunOssProperties aliyun = new AliyunOssProperties();
    /**
     * 腾讯云 COS
     */
    private TencentOssProperties tencent = new TencentOssProperties();
    /**
     * 七牛云
     */
    private QiniuOssProperties qiniu = new QiniuOssProperties();
    /**
     * MinIO
     */
    private MinioProperties minio = new MinioProperties();
    /**
     * Fastdfs
     */
    private FastdfsProperties fastdfs = new FastdfsProperties();

    /**
     * 阿里云 OSS 配置
     */
    @Data
    @EqualsAndHashCode(callSuper = true)
    public static class AliyunOssProperties extends CommonOssProperties {
        /**
         * 是否使用 https
         */
        private Boolean https = false;
    }

    /**
     * 腾讯云 OSS 配置
     */
    @Data
    @EqualsAndHashCode(callSuper = true)
    public static class TencentOssProperties extends CommonOssProperties {
        /**
         * App Id
         */
        private String appId;

        /**
         * 区域简称，https://cloud.tencent.com/document/product/436/6224
         */
        private String region;

        /**
         * 是否使用 https
         */
        private Boolean https = false;
    }

    /**
     * 七牛云存储配置
     */
    @Data
    @EqualsAndHashCode(callSuper = true)
    public static class QiniuOssProperties extends CommonOssProperties {
        /**
         * 区域简称，https://developer.qiniu.com/kodo/manual/1671/region-endpoint
         */
        private String region;
    }

    /**
     * MinIO 配置
     */
    @Data
    @EqualsAndHashCode(callSuper = true)
    public static class MinioProperties extends CommonOssProperties {
    }

    /**
     * Fastdfs 配置
     */
    @Data
    @EqualsAndHashCode(callSuper = true)
    public static class FastdfsProperties extends CommonOssProperties {
    }

    /**
     * 对象存储通用配置
     */
    @Data
    public static class CommonOssProperties extends DefaultProperties {

        /**
         * 对象存储服务的URL
         */
        private String endpoint;

        /**
         * 默认的存储桶名称
         */
        private String bucketName;
    }

}
